package com.lantosec.hmrp.modules.morality.service.impl;

import com.lantosec.hmrp.core.shiro.TokenUtil;
import com.lantosec.hmrp.core.util.DateUtils;
import com.lantosec.hmrp.modules.morality.entity.MoralityNoteBaditem;
import com.lantosec.hmrp.modules.morality.mapper.MoralityNoteBaditemMapper;
import com.lantosec.hmrp.modules.morality.service.IMoralityNoteBaditemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lantosec.hmrp.modules.morality.vo.MoralityNoteBaditemVO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.context.annotation.Primary;
import lombok.extern.log4j.Log4j2;

import java.util.List;

/**
 * <p>
 * 一票认定差的追加记录 服务实现类
 * </p>
 *
 * @author AutoCode
 * @since 2020-04-20
 */
@Service
@Primary
@Log4j2
public class MoralityNoteBaditemServiceImpl extends ServiceImpl<MoralityNoteBaditemMapper, MoralityNoteBaditem> implements IMoralityNoteBaditemService {

    @Override
    public void saveNoteBadItem(List<MoralityNoteBaditemVO> voList) {
        if(CollectionUtils.isNotEmpty(voList)){
            voList.forEach(param->{
                MoralityNoteBaditem entity = param.convertToEntity();
                entity.setCreateUserId(TokenUtil.getUserId());
                entity.setCreateUser(TokenUtil.getName());
                entity.setCreateTime(DateUtils.nowDate());
                this.save(entity);
            });
        }
    }
}
